package com.yowasa.xiuxian.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum  QualityEnum {
    LIE(1, "劣质",0.8),
    LIANG(2, "良品",1.0),
    YOU(3, "优等",1.2),
    JI(4, "极品",1.4),
    JUE(5, "绝妙",1.7),
    SHEN(6,"神话",2.0);
    //类型编号
    private int id;
    //名称
    private String name;

    private double rate;


    public static QualityEnum getById(int id) {
        return Arrays.stream(QualityEnum.values()).filter(e -> e.getId() == id).findFirst().orElse(null);
    }


    public static QualityEnum getByName(String quality) {
        return Arrays.stream(QualityEnum.values()).filter(e -> e.getName().equals(quality)).findFirst().orElse(null);
    }
}
